﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ProductFileClient.LoginHandlerServiceReference;

namespace ProductFileClient
{
    class Program
    {
        static void Main(string[] args)
        {
            LoginTest loginTest = new LoginTest();
            while(!loginTest.TestLogin())
            {
                Console.WriteLine("Please try again!!!");
            }
            
        }
    }

    public class LoginTest
    {
        private LoginHandlerClient m_LoginHandlerProxy = new LoginHandlerClient();

        public bool TestLogin()
        {

            string userName = string.Empty;
            string password = string.Empty;
            Console.Write("Please insert you userName: ");
            userName = Console.ReadLine();
            Console.Write("\nPlease insert you password: ");
            password = Console.ReadLine();
            LoginResult loginResult = m_LoginHandlerProxy.Login(new LoginData { Password = password, UserName = userName });
            string retMessage = string.Empty;
            retMessage = loginResult.RetCode == false ? "\nLogin Failed!!!" : string.Format("\nLogin Succesfull as type {0}", loginResult.UserType);
            Console.WriteLine(retMessage);
            return loginResult.RetCode;

        }
    }
}
